//
//  Factory.m
//  DesignModel
//
//  Created by 赵明明 on 2022/1/5.
//

#import "Factory.h"
#import "prodbase.h"
#import "prod1.h"
#import "prod2.h"


@implementation Factory
+(ProdBase * )create: (NSString*)name{
    ProdBase * prod= nil;
    if([name isEqualToString:@"prod1"]){
        prod = [[prod1 alloc ]init ];
        prod.name=@"prod1";
        //[prod setTitle:prod.name];
        //[prod showTitle];
        [prod setWorkblock:^(ProdBase * _Nonnull prod) {
            prod1 * p1 = [[prod1 alloc]init];
            [p1 setTitle:@"p1"];
            [p1 showTitle];
        }];
       
    }
    if([name isEqualToString:@"prod2"]){
        prod = [[prod2 alloc]init];
        [prod setWorkblock:^(ProdBase * _Nonnull prod) {
            prod2 * p2=[[prod2 alloc] init];
            [p2 showTitle];
        }];
    }
    return prod;
}
@end
